import {
	storage
} from "@/utils/index.js"

const state = {
	token: storage('get', 'token'),
}
const mutations = {
	SET_TOKEN: (state, token) => {
		state.token = token
		storage('set', 'token', token)
	},
}
const actions = {
	/**
	 * token
	 */
	set_token({
		commit
	}, data) {
		commit('SET_TOKEN', data)
	},

	/**
	 * 退出登录
	 */
	logOut({
		commit
	}, data) {
		storage('clear')
	},
}

export default {
	namespaced: true,
	state,
	mutations,
	actions
}
